/* umw.t   ALTERNATE UNIT OF MEASURE MASTER WRITE TRIGGER             */
/*Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                 */
/*All rights reserved worldwide.  This is an unpublished work.        */
/*V8:ConvertMode=NoConvert*/
/*********************************************************************/
/*  Program :umw.t                                                   */
/*  Author  :Gurgen Mkhitaryan  (gym)                                */
/*  Date    :10/17/96                                                */
/*  !Description : um_mstr WRITE trigger program                     */
/*          : In order to enhance this trigger to support additional */
/*          : interfaces, add a DO-END block similar to the one      */
/*          : used for the Warehousing Interface to (1) check for the*/
/*          : need to continue processing; (2) move the relevant     */
/*          : fields to an appropriate work area; and (3) call       */
/*          : one or more subprograms to continue processing.        */
/*          : This .t program should remain short, relying on        */
/*          : subprograms to perform most of the work.               */
/*********************************************************************/
/*                             MODIFY LOG                            */
/*********************************************************************/
/*Revision 8.6          Last Modified:  10/17/96 BY: gym      *K015* */
/*Revision 8.6          Last Modified:  01/07/97 BY: jpm      *J1DM* */
/*Revision 9.1          Last Modified:  08/12/00 BY: *N0KC* myb       */
/*                                                                   */
/*                                                                   */
/*********************************************************************/

trigger procedure for write of um_mstr old buffer old_um_mstr.

         /* THIS TRIGGER PROCEDURE SHOULD MAKE A QUICK CHECK FOR ANY */
         /* ROUTINES THAT NEED TO BE EXECUTED AS A RESULT OF THIS    */
         /* TRIGGER FIRING. IF NO ROUTINES NEED TO BE CALLED THEN    */
         /* RETURN WITHOUT DOING ANYTHING.                           */


         /* GLOBAL VARIABLES */
         {mfdeclre.i}

         /* LOCAL VARIABLES */
         define variable warehousing_active as logical no-undo.

         /* SHARED WORK TABLES */
         define new shared variable w-site-loc-id like whl_mstr.whl_src_dest_id.
         define new shared work-table wf_old_um_mstr like um_mstr.


         WI: /* WAREHOUSING INTERFACE PROCESSING */
         do:

             warehousing_active = true.

             /* CHECK IF WAREHOUSE INTERFACE IS ACTIVE */
             if not can-find(first whl_mstr no-lock
                 where whl_mstr.whl_act and whl_mstr.whl_um_exp)
             then warehousing_active = false.

            /* If no pertinent fields have been changed, then do not process */
             if   (old_um_mstr.um_um       = um_mstr.um_um
               and old_um_mstr.um_alt_um   = um_mstr.um_alt_um
               and old_um_mstr.um_conv     = um_mstr.um_conv
               and old_um_mstr.um_part     = um_mstr.um_part
               and old_um_mstr.um_desc     = um_mstr.um_desc
               and old_um_mstr.um_alt_qty  = um_mstr.um_alt_qty
               and old_um_mstr.um_user1    = um_mstr.um_user1
               and old_um_mstr.um_user2    = um_mstr.um_user2)
             then warehousing_active = false.


             if warehousing_active then do:

                 /* COPY THE OLD RECORD BUFFER INTO THE WORKFILE FOR  */
                 /* LATER COMPARISONS TO THE NEW RECORD BUFFER        */

                 create wf_old_um_mstr.
                 assign
                     wf_old_um_mstr.um_um       = old_um_mstr.um_um
                     wf_old_um_mstr.um_alt_um   = old_um_mstr.um_alt_um
                     wf_old_um_mstr.um_conv     = old_um_mstr.um_conv
                     wf_old_um_mstr.um_part     = old_um_mstr.um_part
                     wf_old_um_mstr.um_desc     = old_um_mstr.um_desc
                     wf_old_um_mstr.um_alt_qty  = old_um_mstr.um_alt_qty
                     wf_old_um_mstr.um_user1    = old_um_mstr.um_user1
                     wf_old_um_mstr.um_user2    = old_um_mstr.um_user2
                     .

                 /* WAREHOUSE INTERFACE VP_MSTR WRITE ROUTINE */
/*J1DM*/ /*      {gprun.i ""wiumw.p"" "(recid(um_mstr))"} */
/*J1DM*/         {gprunmo.i &module="WI"
                            &program="wiumw.p"
                            &param="(recid(um_mstr))"}

             end. /* IF WAREHOUSE INTERFACE ACTIVE */

         end. /* WI */

HK:
do:
    if can-find(first dt_mstr where dt_table = "um_mstr" and dt_type = "SYNC") then
        run CreateSyncFlag(input "MOD", input recid(um_mstr), input "um_mstr").
end.

{hkdttrans.i}
